//
//  OMOrderEvaluateDetailInfoTableCell.m
//  OMENGO_NEW
//
//  Created by 梁尚嘉 on 2017/5/17.
//  Copyright © 2017年 Kamfat. All rights reserved.
//

#import "OMOrderEvaluateDetailInfoTableCell.h"
#import "OMOrderEvaluateStarTableCell.h"
#import "OMEvaluation.h"
@interface OMOrderEvaluateDetailInfoTableCell ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UILabel *elementLabel;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong)OMOrderEvaluateStarTableCell *shopCell;
@property (nonatomic, strong)OMOrderEvaluateStarTableCell *shipCell;
@property (nonatomic, strong)OMOrderEvaluateStarTableCell *menCell;
@end

@implementation OMOrderEvaluateDetailInfoTableCell
{
    NSArray *_starArray;
}

- (void)configure
{
    [super configure];
    _elementLabel = [UILabel new];
    _elementLabel.text = @"· 好评 ·";
    _elementLabel.font = SM_CBFont(45);
    _elementLabel.textColor = SM_blackColor;
    [self.contentView addSubview:_elementLabel];
    [_elementLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@(SM_SIZE(50)));
        make.centerX.equalTo(self.contentView.mas_centerX);
    }];

    _tableView = [[UITableView alloc]init];
    _tableView.backgroundColor = SM_whiteColor;
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.scrollEnabled = NO;
    _tableView.clipsToBounds = YES;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.contentView addSubview:_tableView];
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(@(SM_SIZE(0)));
        make.top.equalTo(self.elementLabel.mas_bottom).offset(SM_SIZE(50));
        make.height.equalTo(@(3*[OMOrderEvaluateStarTableCell cellHeight]));
        make.bottom.equalTo(@(SM_SIZE(-50)));
    }];

    _shopCell = [OMOrderEvaluateStarTableCell new];
    _shopCell.userInteractionEnabled = NO;
    _shopCell.elementLabel.text = @"商家服务";
    _shipCell = [OMOrderEvaluateStarTableCell new];
    _shipCell.userInteractionEnabled = NO;
    _shipCell.elementLabel.text = @"配送服务";
    _menCell = [OMOrderEvaluateStarTableCell new];
    _menCell.userInteractionEnabled = NO;
    _menCell.elementLabel.text = @"人员服务";
    _starArray = @[_shopCell,_shipCell,_menCell];

}

- (void)configureCellWithObj:(OMEvaluation *)evaluation
{
    if (!evaluation.score)//好评
    {

    }
    else //差评
    {
        _elementLabel.text = @"· 差评 ·";
        [self.tableView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.equalTo(@0);
            make.bottom.equalTo(@0);
        }];
    }
    self.shopCell.starView.point = evaluation.shop_score;
    self.shipCell.starView.point = evaluation.delivery_score;
    self.menCell.starView.point = evaluation.people_score;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _starArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return _starArray[indexPath.row];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [OMOrderEvaluateStarTableCell cellHeight];
}


@end
